﻿using MengLin.OOP.DesignPattern.Adapter.ServiceCanUsed.Entity;
using MengLin.OOP.DesignPattern.Adapter.ServiceCanUsed.Implements;
using MengLin.OOP.DesignPattern.Adapter.ServiceCanUsed.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MengLin.OOP.DesignPattern.Adapter.ServiceCanUsed
{
    class Program
    {
        static void Main(string[] args)
        {
            #region SqlServer
            {
                IDBHelper helper = new SqlServerHelper();
                helper.Add<Student>();
                helper.Update<Student>();
                helper.Delete<Student>();
                helper.Query<Student>();
            }
            #endregion

            #region MySql
            {
                IDBHelper helper = new MySqlHelper();
                helper.Add<Student>();
                helper.Update<Student>();
                helper.Delete<Student>();
                helper.Query<Student>();
            }
            #endregion

            #region 原始的RedisHelper的使用方式(和开发规范不统一,人家都是Add,Update,Delete,Query)
            {
                RedisHelper helper = new RedisHelper();
                helper.AddRedis<Student>();
                helper.UpdateRedis<Student>();
                helper.DeleteRedis<Student>();
                helper.QueryRedis<Student>();
            }
            #endregion

            #region 继承方式(和开发规范保持一致,都用Add,Update,Delete,Query)
            {
                IDBHelper helper = new RedisInheritHelper();
                helper.Add<Student>();
                helper.Add<Student>();
                helper.Update<Student>();
                helper.Delete<Student>();
                helper.Query<Student>();
            }
            #endregion

            #region 组合方式(和开发规范保持一致,都用Add,Update,Delete,Query)
            {
                IDBHelper helper1 = new RedisComposeHelper();
                IDBHelper helper2 = new RedisComposeHelper(new RedisHelper());//构造函数注入
                RedisComposeHelper helper3 = new RedisComposeHelper();//方法注入
                helper3.SetRedisHelper(new RedisHelper());
                helper1.Add<Student>();
                helper1.Add<Student>();
                helper1.Update<Student>();
                helper1.Delete<Student>();
                helper1.Query<Student>();
            }
            #endregion
        }
    }
}
